from datetime import datetime

from sqlalchemy import Column, Integer, String, CHAR, DECIMAL

from models.base import Base


class User(Base):
    __tablename__ = 'user'
    id = Column(Integer, autoincrement=True, primary_key=True)
    create_time = Column(Integer, default=0)
    nickname = Column(String(50), default='')
    avatar = Column(String(100), default='')
    gzh_open_id = Column(String(100), default='')
    mp_open_id = Column(String(100), default='')
    union_id = Column(String(100), default='')
    remain = Column(Integer, default=0)
    role_id = Column(Integer, default=5)
    amount = Column(DECIMAL(9, 2), default=0)

    def __init__(self):
        self.create_time = int(datetime.now().timestamp())
